// js实现动态变化的数字
const directive = {
  inserted(el, binding) {
    // .....
    let timer = setInterval(() => {
      count = count + step;
      if( count < 1000 ){
        // binding.value.bUnit是我们通过指令传递进来的参数
        el.innerText = count.toFixed(0) +  binding.value.bUnit
      }else{
        el.innerText = (count / 1000 ).toFixed(0) + binding.value.eUnit
      }
      if (count > finalNum) {
      //  避免count大于finalNum最终数字显示不对
        count = finalNum;
        if( count < 1000 ){
          el.innerText = count.toFixed(0) + binding.value.bUnit
        }else{
          el.innerText = (count / 1000 ).toFixed(0) + binding.value.eUnit
        }
        // 清空定时器
        clearInterval(timer);
        timer = null;
      }
    }, rate);
  },
};
export default directive;
